<?php

namespace App\Http\Controllers;

use App\Http\Requests\UserLoginRequest;
use Illuminate\Http\Request;
use Gate;

class AuthController extends Controller
{
    //
    public function login(){
        return view('admin.home.login');
    }
    public function signin(UserLoginRequest $request){
        if(\Auth::attempt([
            'email'=>$request->get('email'),
            'password'=>$request->get('password'),
        ])){
            if (Gate::denies('unable')) {
                return redirect('admin/');
            }
            else{
                \Session::flash('user_login_failed','账号被封禁');
            }
        }
        \Session::flash('user_login_failed','密码不正确或没有验证');
        return redirect('auth/user/login')->withInput();
    }
    public function logout(){
        \Auth::logout();
        return redirect('/admin');
    }
    public function home(){
        $pagehead  = '管理面板';
        $pagename  = '管理面板';
        $modelurl  = '';
        return view('admin.home.home',compact('pagehead','pagename','modelurl'));
    }

}
